package cn.edu.zime.tjh47;

import android.content.Intent;
import android.os.Bundle;
import android.widget.ListView;
import android.widget.SimpleAdapter;

import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Full extends AppCompatActivity {
    ListView listView;
    Class<?>[] aClass = {Class2_01.class, Class2_02.class, Class2Button.class, Class2Login.class, Class3_01.class, Class3_02.class, Class3Card.class, Class3Calculator.class, Class4ActivityJump.class, Class5_1.class,Class6_1.class, Class6_2.class, Class7ListView.class, Class8.class, Class10.class, Class11.class, Class12_1.class, Class12_2.class};
    String[] arr = {"第2课示例任务1", "第2课示例任务2", "第2课作业1", "第2课作业2", "第3课示例任务", "第3课作业1", "第3课作业2", "第3课作业3", "活动跳转", "猜数字", "选城市", "选班级","第七课ListView","第八课第九课集成","第十课登录功能","学生信息管理","示例任务1：WEBVIEW","示例任务二：UrlConnect"};
    int[] to = new int[]{R.drawable.f1, R.drawable.m1, R.drawable.f2, R.drawable.m2, R.drawable.f3, R.drawable.m3, R.drawable.f4, R.drawable.m4, R.drawable.f5, R.drawable.m5, R.drawable.f6, R.drawable.m6,R.drawable.f1, R.drawable.f3, R.drawable.m3, R.drawable.m6, R.drawable.m4, R.drawable.f4, R.drawable.m2};

    List<Map<String,Object>> list;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.full);
        listView = findViewById(R.id.lv_list);
        list = new ArrayList<>();
        for (int i = 0; i < arr.length; i++) {
            Map<String, Object> map = new HashMap<>();
            map.put("tv_name", arr[i]);
            map.put("img_head", to[i]);
            list.add(map);
        }
        String[] key = {"tv_name", "img_head"};
        int[] To = new int[]{R.id.tv_name,R.id.img_head};
        SimpleAdapter adapter = new SimpleAdapter(this, list, R.layout.class7_item, key,To);
        listView.setAdapter(adapter);
        listView.setOnItemClickListener((parent, view, position, id) -> {
            Intent intent = new Intent(Full.this, aClass[position]);
            startActivity(intent);
        });

    }


}